#include<iostream>
using namespace std;
int main()
{int n,a,b,s;
 while(cin>>n)
   {int max=0,d=0;
         if(n==0) break;
    for(int i=1;i<=n;i++)
       {  cin>>a>>b;
          if(a+b>8) {s=a+b;if(a+b>max)  {max=a+b;d=i;}}
       }
    cout<<d<<endl;
 }
system("pause");
return 0;
}
